package tests;

import junit.framework.Assert;

import org.junit.Before;
import org.junit.Test;

import exceptions.InvalidAddressCity;
import exceptions.InvalidAddressComplement;
import exceptions.InvalidAddressCountry;
import exceptions.InvalidAddressNeighborhood;
import exceptions.InvalidAddressState;
import exceptions.InvalidAddressStreet;
import exceptions.InvalidUserUsername;
import exceptions.InvalidUserName;
import exceptions.InvalidUserAddress;

import root.MainManager;
import root.user.User;
import strategy.AbstractStrategyFactory;


public class UserTest {
	final String username = "testclass";
	final String name = "test@test.com";
	final String wrongUsername = "LOL";
	final String wrongName = "LOL";
	/*
	 * Pais, Estado, Cidade, Bairro, Rua, Numero, Complemento
	 */
	//private Address address;
	private User user;
	private String address = "oi";
	@Before
	public void set_up() throws InvalidAddressCountry, InvalidAddressState, InvalidAddressCity, InvalidAddressNeighborhood, InvalidAddressStreet, InvalidAddressComplement, InvalidUserUsername, InvalidUserName, InvalidUserAddress {
		//address = new Address("Brasil", "Paraiba", "Joao Pessoa", "Manaira", "Rua Joaquim", 333, "");
		MainManager.zerarSistema();
		user = new User(username, name, address,AbstractStrategyFactory.getInstance());
	}
	
	@Test
	public void testGetUsername() {
		Assert.assertEquals(username, user.getUsername());
		Assert.assertEquals(false, wrongUsername.equals( user.getUsername() ));
	}
	
	@Test
	public void testGetName() {
		Assert.assertEquals(name, user.getName());
		Assert.assertEquals(false, wrongName.equals(user.getName()));
	}
	
	@Test
	public void testGetAddress() {
		Assert.assertEquals(address, user.getAddress());
	}
	
	@Test(expected=InvalidUserUsername.class)
	public void usernameInvalidTest() throws InvalidUserUsername, InvalidUserName, InvalidUserAddress {
		new User(null, name, address,AbstractStrategyFactory.getInstance());
		
	}
	
	@Test(expected=InvalidUserName.class)
	public void nameInvalidTest() throws InvalidUserUsername, InvalidUserName, InvalidUserAddress {
		new User(username, null, address,AbstractStrategyFactory.getInstance());
		
	}
	
	@Test(expected=InvalidUserAddress.class)
	public void addressInvalidTest() throws InvalidUserUsername, InvalidUserName, InvalidUserAddress {
		new User(username, name, null,AbstractStrategyFactory.getInstance());
	}
	
	
	
	
	
	
}
